import os

import urllib.request

image_url = 'http://n.sinaimg.cn/news/crawl/117/w550h367/20220417/a3a9-08b2ca6dffe4210149dda424adf0734f.jpg'

file_path = 'C:/Users/Administrator/Desktop/a3a9-08b2ca6dffe4210149dda424adf0734f.jpg'
try:
    if not os.path.exists(file_path):
        os.makedirs(file_path)
    file_suffix = os.path.splitext(image_url)[1]
    print(file_suffix)
    filename = '{}{}'.format(file_path, file_suffix)
    print(filename)
    urllib.request.urlretrieve(image_url, filename=filename)
    print(11111)

except IOError as e:
    print(1, e)

except Exception as e:
    print(2, e)
